<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>

  <h1 class="time"></h1>
  <script>
    
    function padLeft(content, count, padstr) {
      
      count = count || 2
      padstr = padstr || "0"
      
      content = String(content)
      return content.padStart(count, padstr)
    }

    var timeEl = document.querySelector(".time")

    setInterval(function() {
      
      var date = new Date()
      var year = padLeft(date.getFullYear())
      var month = padLeft(date.getMonth())
      var day = padLeft(date.getDate())
      var hour = padLeft(date.getHours())
      var mintue = padLeft(date.getMinutes())
      var second = padLeft(date.getSeconds())

      timeEl.textContent = `${year}-${month}-${day} ${hour}:${mintue}:${second}`
    },1000)
    
    var mes

    // while (true) {
      for(var i = 0; i < 10; i++ ) {
        // var mes = prompt("请输入")
        if (!mes) {
          break
        }
        var divEl = document.createElement("div")
        divEl.textContent = mes
        divEl.style.color = "red"
        document.body.after(divEl)
      }
      
    // }
    
  </script>
</body>
</html>